/*--------------------------------------------------------------------------------
 * Adaptive Intelligence - Foundation Framework Class Library
 * Version 2.00
 * 
 * Thread Implementation Interface Definition
 *      Provides a common definition for classes used to implement specific 
 * threaded operations.
 *------------------------------------------------------------------------------*/

/*--------------------------------------------------------------------------------
 * System Imports
 *------------------------------------------------------------------------------*/
using System;
using System.IO;
using System.Threading;

namespace Adaptive.Foundation
{
    /// <summary>
    /// Provides a common definition for classes used to implement specific 
    /// threaded operations.
    /// </summary>
    public interface IThreadImplementation
    {
        /*--------------------------------------------------------------------------------
         * Public Event Declarations
         *------------------------------------------------------------------------------*/
        #region Public Event Declarations
        /// <summary>
        /// Occurs when the thread is launched.
        /// </summary>
        event EventHandler ThreadLaunched;
        /// <summary>
        /// Occurs when the thread is terminated.
        /// </summary>
        event EventHandler ThreadStopped;
        /// <summary>
        /// Occurs when an exception is captured within the thread.
        /// </summary>
        event EventHandler ThreadedException;
        /// <summary>
        /// Occurs when a deadlock is detected.
        /// </summary>
        event EventHandler DeadlockDetected;
        #endregion

        /*--------------------------------------------------------------------------------
         * Public Properties
         *------------------------------------------------------------------------------*/
        #region Public Properties
        /// <summary>
        /// Gets the reference to the thread being executed.
        /// </summary>
        /// <value>
        /// A <see cref="Thread"/> instance if active; otherwise, <b>null</b>.
        /// </value>
        Thread Thread { get; }
        /// <summary>
        /// Gets a value indicating whether the thread is currently active.
        /// </summary>
        /// <value>
        /// <b>true</b> if the thread is running; otherwise, <b>false</b>.
        /// </value>
        bool ThreadExecuting { get; }
        /// <summary>
        /// Gets or sets the name assigned to the threaded operation.
        /// </summary>
        /// <value>
        /// A name for the threaded operation instance.
        /// </value>
        string Name { get; set;}

        #endregion

        /*--------------------------------------------------------------------------------
         * Public Methods / Functions
         *------------------------------------------------------------------------------*/
        #region Public Methods / Functions
        /// <summary>
        /// Begins execution of the threaded operation.
        /// </summary>
        void StartThread();
        /// <summary>
        /// Terminates execution of the threaded operation.
        /// </summary>
        void TerminateThread();
        /// <summary>
        /// Resets the operation of the thread.
        /// </summary>
        void ResetThread();
        #endregion
    }
}